﻿using System;
using System.IdentityModel.Claims;
using Altairis.IdentityToolkit;

public partial class UnlinkedLive : System.Web.UI.Page {

    private string csid;
    private ClaimSet cs;

    protected void Page_Load(object sender, EventArgs e) {
        // Get ClaimSet cache ID
        this.csid = Request.QueryString["CSID"];
        this.cs = this.Cache[csid] as ClaimSet; 
    }

    protected void ButtonContinue_Click(object sender, EventArgs e) {
        Response.Redirect("~/Auth/Default.aspx");
    }

    protected void ButtonYes_Click(object sender, EventArgs e) {
        // Get suitable provider
        var p = IdentityLinkManager.Providers.Find(this.cs);
        p.CreateLink(this.cs, this.User.Identity.Name);

        // Remove the ClaimSet from cache
        this.Cache.Remove(this.csid);

        // Redirect to main page
        Response.Redirect("~/Auth/Default.aspx");
    }

    protected void ButtonNo_Click(object sender, EventArgs e) {
        // Remove the ClaimSet from cache
        Cache.Remove(this.csid);

        // Redirect to main page
        Response.Redirect("~/Auth/Default.aspx");
    }
}
